<template>
	<view class="page">

		<mescroll-uni ref="mescrollRef" @init="mescrollInit" @down="downCallback" :top="'10rpx'" @up="upCallback">
			<!-- :down="downOption" :up="upOption" -->

			<uni-list>
				
				<orderListItem v-for="(item, index) in listdata" :key="index" :itemData="item">
					
				</orderListItem>

				
			</uni-list>

		</mescroll-uni>

	</view>
</template>

<script>
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import orderListItem from '@/components/order/order-list-item.vue';

	export default {
		mixins: [MescrollMixin],
		components: {
			orderListItem
		},
		data() {
			return {
				page: 1,
				listdata: [],
				customerId: '',
				carId: '',
				type: '',
			}
		},
		onLoad(op) {
			this.customerId = op.customerId;
			this.carId = op.carId;
			this.type = op.type;
			this.getData();
			
		},
		methods: {
			getData() {
				
				let params = 'member'==this.type?{
					pageNo: this.page,
					customerId: this.customerId,
				}:{
					pageNo: this.page,
					carId: this.carId,
				}

				this.$u.api.orderlist(params).then(
						res => {


							if (this.page == 1) {
								this.listdata = [];
							}
							
							this.listdata = this.listdata.concat(res);
              this.mescroll.endSuccess(res.length);
						}
					)
					.catch(() => {
						this.mescroll.endErr();
					})
			},

			upCallback(page) {
				console.log("触发了上拉加载" + page);

				this.page = page.num;
				this.getData();
			},


		}
	}
</script>

<style lang="scss">
	.page {
		background-color: $grayf5;
	}

	.item {
		display: flex;
		flex-direction: column;
		background-color: white;
		border-radius: 8rpx;
		margin: 10rpx 20rpx;
		padding-bottom: 10rpx;
	}

	.title {
		width: 80%;
		height: 80rpx;
		line-height: 80rpx;
		font-size: 28rpx;
		white-space: nowrap;
		text-overflow: ellipsis;
		overflow: hidden;
		color: $black33;
		margin-left: 20rpx;
	}

	.text-warn {
		font-size: 24rpx;
		color: $rede9;
		margin-right: 20rpx;
	}

	.text-warn-orange {
		color: $yellowffc;
	}

	.btn-detail {
		width: 180rpx;
		height: 60rpx;
		border-radius: 50rpx;
		color: white;
		text-align: center;
		background-color: $blue15;
		font-size: 26rpx;
		line-height: 60rpx;
		margin: 10rpx 20rpx 10rpx;
		align-self: flex-end;
	}
</style>
